package com.stx.test.classArray;

import java.util.Scanner;

/**
 * packageName com.stx.day0916
 *
 * @author YangYi
 * @className SixParts
 * @date 2025/9/16
 * @description TODO
 */
public class SixParts {
    Scanner scanner = new Scanner(System.in);
    Students[] students ;

    public void meun() {
        boolean isExist = false;
        while (!isExist) {
            System.out.println("*****************");
            System.out.println("**欢迎来到晨翊六部**");
            System.out.println("****1、添加成员****");
            System.out.println("****2、扣除分数****");
            System.out.println("****3、加分数****");
            System.out.println("****4、展示成员****");
            System.out.println("****5、退出系统****");
            System.out.println("*****************");
            int choose = scanner.nextInt();
            switch (choose) {
                case 1: {
                    addStudent();
                    break;
                }
                case 2: {
//                    deductScores();
                    break;
                }
                case 3: {
//                    addScores();
                    break;
                }
                case 4: {
                    shows();
                    break;
                }
                case 5: {
                    System.out.println("退出系统");
                    System.exit(0);
                    break;
                }
                default: {
                    System.out.println("输入有误！！！");
                }
            }
        }
    }
    /**
     * 新增
     */
    public void addStudent() {
        Students student = new Students();
        System.out.println("请输入姓名：");
        String name = scanner.next();
        student.setName(name);
        System.out.println("请输入学号：");
        int num = scanner.nextInt();
        student.setNum(num);
        System.out.println("请输入默认分数：");
        double scores = scanner.nextDouble();
        student.setScores(scores);
        System.out.println("请输入年龄：");
        int age = scanner.nextInt();
        student.setAge(age);
        System.out.println("请输入电话：");
        String mobile = scanner.next();
        student.setMobile(mobile);
        System.out.println("请输入性别：");
        String sex = scanner.next();
        student.setSex(sex);
        for (int i = 0; i < students.length; i++) {
            if (students[i] == null) {
                students[i] = student;
                System.out.println("添加成功");
                break;
            }
        }
        System.out.println("退出添加");
    }

    public void shows() {
        for (int i = 0; i < students.length; i++) {
            if (students[i] != null) {
                System.out.println("学号：" + students[i].getNum() +
                        "，姓名：" + students[i].getName() + "，分数：" +
                        students[i].getScores() + "，年龄：" + students[i].getAge() +
                        "，电话："+students[i].getMobile()+"，性别："+students[i].getSex());
            }
        }
    }
}
